-
Notifications
You must be signed in to change notification settings - Fork 5
🩹 [Patch]: Add New-GitHubOrganization
function
#462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s in a specified enterprise
…ository Rule Suites (Insights) (#461) ## Description This pull request introduces several changes across multiple files to enhance the functionality and structure of GitHub-related classes in the codebase. The most notable updates include replacing `HostName` with `GitHubContext` for improved context management, restructuring properties in `GitHubOwner` subclasses, and updating XML format definitions to reflect the new structure. - Fixes #454 ### Context Management Updates: * Replaced the `HostName` parameter with `GitHubContext` in constructors across multiple classes (`GitHubAppInstallation`, `GitHubArtifact`, `GitHubEnvironment`, `GitHubOrganization`). This change centralizes context-related properties, such as `HostName`, for better scalability and readability. ### GitHubOwner Class Restructuring: * Removed redundant properties (e.g., `Company`, `Blog`, `Plan`) from the `GitHubOwner` class and its subclasses (`GitHubEnterprise`, `GitHubOrganization`, `GitHubUser`). Added new properties such as `Description` and `Website` to better align with GraphQL schema mappings. ### GraphQL Mapping Enhancements: * Introduced static `$PropertyToGraphQLMap` hashtables in `GitHubEnterprise` and `GitHubOrganization` classes to define mappings between class properties and GraphQL fields, improving maintainability and integration with GraphQL APIs. ### XML Format Updates: * Updated the `GitHubOwner.Format.ps1xml` file to include new properties (`DisplayName`, `CreatedAt`) in table views for improved visualization of `GitHubOwner` objects. Removed deprecated columns such as `Company` and `Plan`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ]⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
- Created TEMPLATE.ps1 for Pester testing framework setup. - Added Teams.Tests.ps1 to test GitHub Teams API functionalities. - Introduced Users.Tests.ps1 for user-related API tests. - Developed Variables.Tests.ps1 to manage GitHub repository variables. - Each test script includes setup and teardown logic for authentication and resource cleanup. - Implemented various test cases for creating, updating, retrieving, and deleting GitHub resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the New-GitHubOrganization
function and harmonizes several parameter names and context handling across the module.
- Introduces
New-GitHubOrganization
for creating organizations via GraphQL mutations. - Renames
Blog
→Website
andBio
→Description
in user/org cmdlets and tests. - Replaces
HostName
parameters withGitHubContext
objects and updates constructors accordingly.
Reviewed Changes
Copilot reviewed 48 out of 59 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/Organizations.Tests.ps1 | Adds setup/teardown for enterprise orgs; new New-GitHubOrganization test |
test2/Users.Tests.ps1 | Updates Update-GitHubUser tests to use -Website /-Description and asserts new properties |
test2/Enterprise.Tests.ps1 | Adjusts enterprise tests to skip non-enterprise and validate Website |
src/functions/public/Organization/New-GitHubOrganization.ps1 | Implements creation via GraphQL for new orgs |
src/functions/public/Users/Update-GitHubUser.ps1 | Renames -Bio to -Description and -Blog to -Website |
src/functions/public/Organization/Update-GitHubOrganization.ps1 | Renames parameters and updates request body mappings |
src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 | Removed org alias on $Owner parameter |
src/classes/public/Owner/GitHubOwner/GitHubOrganization.ps1 | Updates constructor to use GitHubContext ; adds new properties and fallback logic |
Comments suppressed due to low confidence (2)
src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1:41
- Removing the
org
alias for the$Owner
parameter breaks backward compatibility. Consider keeping the alias or updating documentation/examples to use the new parameter name explicitly.
[Parameter()]
.github/PSModule.yml:18
- [nitpick] Setting
Skip: true
forCodeCoverage
while also specifying aPercentTarget: 50
is contradictory. Either remove the skip or adjust the coverage target to ensure coverage metrics are enforced.
Skip: true
…Install-GitHubAppOnEnterpriseOrganization function; remove obsolete tests from Organizations.Tests
… of Organizations.Tests
… wildcard matching and add -WhatIf parameter for safety
…ubOrganization function
…y parameters for organization name and owners; improve debug logging in process block
…ion's begin block
…g organization details before removal; improve organization retrieval in tests
… parameter for organization retrieval in enterprise context; ensure accurate logging of organizations
…e unnecessary enterprise parameter and cleanup calls
… parameter for organization retrieval in enterprise context
…xt using Invoke-GitHubAPI
…or enterprise context
…g unnecessary logging and directly removing organizations for enterprise context
…-GitHubOrganization function
…r enterprise cleanup
…d add tests for app installation and organization updates
…xceptions for non-enterprise installations
- Created TEMPLATE.ps1 for standardized test structure. - Implemented Teams.Tests.ps1 to validate GitHub Teams functionality, including team creation, retrieval, updating, and deletion. - Developed Users.Tests.ps1 to test user-related API calls, including user retrieval and updates. - Added Variables.Tests.ps1 to cover GitHub variable management, including setting, updating, and removing variables for users and organizations. - Each test file includes setup and teardown logic to ensure a clean testing environment. - Utilized Pester's logging capabilities to enhance output visibility during test execution.
Module GitHub - 0.33.8 published to the PowerShell Gallery. |
GitHub release for GitHub v0.33.8 has been created. |
Description
This pull request introduces several new features and improvements to the PowerShell module for managing GitHub organizations and apps. Key changes include new functions for creating and managing organizations, enhancements to app installation workflows, and updates to testing coverage for these functionalities.
New-GitHubOrganization
#459New and updated functions
New-GitHubOrganization
function to create GitHub organizations within a specified enterprise. This includes support for specifying owners, billing emails, and enterprise contexts.Remove-GitHubOrganization
function to support removing multiple organizations via an array input parameter, improving flexibility.Improvements to App Installation
Install-GitHubAppOnEnterpriseOrganization
function to validate repository selection values case-insensitively and return strongly-typedGitHubAppInstallation
objects.Updates to Organization Properties
GitHubOrganization
class to ensure accurate handling ofRequireWebCommitSignoff
.Testing Enhancements
Debugging Improvements
Invoke-GitHubAPI
to include detailed context information in error messages, aiding debugging efforts.Type of change
Checklist